const common = require('./webpack.common')
const { merge } = require('webpack-merge')

module.exports = merge(common, {
    mode: 'development',
    devtool: 'cheap-module-eval-source-map',
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: 'eslint-loader',
                enforce: 'pre'
            }
        ]
    },
    devServer: {
        contentBase: './public',
        proxy: { //配置API地址
            '/api': { //以api开头的地址
                target: 'https://api.example.com', //代理目标
                pathRewrite: {
                    '^/api': '' //api前面的字符替换为空
                },
                changeOrigin: true //不能使用localhost:8080作为请求github的主机名
            }
        }
    }
})